/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSkyRoom.finder;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import ru.jSkyRoom.interfaces.JSkyMod;
import ru.jSkyRoom.interfaces.major.Major;
import skyproc.FormID;
import skyproc.GRUP_TYPE;
import skyproc.MajorRecord;
import skyproc.Mod;

/**
 *
 * @author Rakev
 */
public class FromModByFormIdFinder<T extends Major> extends AbstractFinderByFormId<T> {

    private JSkyMod mod;
    private GRUP_TYPE[] lookingGrups;

    public FromModByFormIdFinder(JSkyMod mod, GRUP_TYPE... lookingGrups) {
        this.mod = mod;
        this.lookingGrups = lookingGrups;
    }

    @Override
    public T find(FormID id) {
        if (isNullFormId(id)) {
            return null;
        }
        return (T) mod.getMajor(id, lookingGrups);
    }

    private boolean isNullFormId(FormID id) {
        return id == null || id.isNull() || id.toString().startsWith("000000");
    }
}
